<template>
  <div>
    <h3 style="color: black">个人身份认证</h3>
    <el-descriptions>
      <el-descriptions-item label="姓名">{{ driver.realName }}</el-descriptions-item>
      <el-divider></el-divider>
      <el-descriptions-item label="手机号">{{ driver.phone }}</el-descriptions-item>
      <el-divider></el-divider>
      <el-descriptions-item label="身份证号">{{ driver.idCard }}</el-descriptions-item>
      <el-divider></el-divider>

      <el-descriptions-item label="身份证正面照">
        <img class="a_img" :src="'http://localhost:19283'+driver.positiveIdCard">
      </el-descriptions-item>

      <el-descriptions-item label="身份证反面照">
        <img class="a_img" :src="'http://localhost:19283'+driver.negativeIdCard">
      </el-descriptions-item>

      <el-descriptions-item label="驾驶证照">
        <img class="a_img" :src="'http://localhost:19283'+driver.driverIdCard">
      </el-descriptions-item>

    </el-descriptions>

    <el-button size="mini"
               type="success"
               v-if="driver.auditStatus==2"
               @click="handleSuccess()">通过
    </el-button>

    <el-button
        size="mini"
        type="danger"
        v-if="driver.auditStatus==2"
        @click="handleDelete()">驳回
    </el-button>
  </div>
</template>

<script>
export default {
  name: "AdminAuditDetailView",
  data() {
    return {
      driver: {}
    }
  },
  methods: {
    handleSuccess() {
      let u = {id: this.driver.id, auditStatus: 1};
      let data = this.qs.stringify(u)
      this.axios.post('http://localhost:19281/admin/driver/audit/save', data)
          .then((response) => {
            if (response.data.state == 20000) {
              this.$message.success("操作成功！")
              this.$router.push("/admin/audit")
            }
          })
    },
    handleDelete() {
      let u = {id: this.driver.id, auditStatus: 0};
      let data = this.qs.stringify(u)
      this.axios.post('http://localhost:19281/admin/driver/audit/save', data)
          .then((response) => {
            if (response.data.state == 20000) {
              this.$message.success("操作成功！")
              this.$router.push("/admin/audit")
            }
          })
    }
  },
  mounted() {
    let id = new URLSearchParams(location.search).get('id')
    this.axios.get('http://localhost:19281/admin/driver/' + id).then((response) => {
      if (response.data.state == 20000) {
        this.driver = response.data.data
      }
    })
  }
}
</script>

<style scoped>

</style>